package com.cortex.pineapple.adapters;

import java.util.List;

import com.cortex.pineapple.R;
import com.cortext.pineapple.link.Link;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;


public class FilterAdapter extends BaseAdapter {

	protected Context context;
	protected String[] filters;
	private String hint;
	private boolean isSelected;
	
	public FilterAdapter(Context context, String[] filters,String hint) {
		this.context = context;
		this.filters = filters;
		this.hint = hint;
	}

	@Override
	public int getCount() {
		return filters.length;
	}

	@Override
	public Object getItem(int position) {
		return filters[position];
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		TextView filter = (TextView) convertView;
		int positionTemp = position;
		if(filter == null){
			LayoutInflater inflater = LayoutInflater.from(context);
			filter = (TextView)inflater.inflate(R.layout.view_item_filter, null);
			convertView = filter;
		}
		filter.setText(filters[positionTemp]);
		if(!isSelected){
			filter.setText(hint);	
		}
		return convertView;
	}

	@Override
	public View getDropDownView(int position, View convertView, ViewGroup parent) {
		TextView filter = (TextView) convertView;
		int positionTemp = position;
		if(filter == null){
			LayoutInflater inflater = LayoutInflater.from(context);
			filter = (TextView)inflater.inflate(R.layout.view_item_filter, null);
			convertView = filter;
		}
		filter.setText(filters[positionTemp]);
		isSelected = true;
		return convertView;
	}
	public String getHint(){
		return hint;
	}

}
